import request from '@/utils/request'

// 查询需求列表
export function listdemand(query) {
  return request({
    url: '/bidding/demand/demandList',
    method: 'get',
    params: query
  })
}

// 查询明细列表
export function listDetail(query) {
  return request({
    url: '/bidding/demand/applicationList',
    method: 'post',
    params: query
  })
}

export function insertDemandMain(query){
  var json = JSON.stringify(query);
  console.info(json);
  return request({
    url:'/bidding/demand/addDemandMain',
    method:'post',
    data:json,
  })
}

export function getDemandMain(query){
  return request({
    url:'/bidding/demand/findAllByProjectID',
    method:'post',
    data: {"projectID":Number(query)}
  })
}

export function updateDemandMain(query){
  return request({
    url:'/bidding/demand/updateByProjectID',
    method:'post',
    data:query,
  })
}

export function delDemandMain(query){
  console.info(query);
  let arr1 = [];
  if (Array.isArray(query)) {
    // 如果query是一个数组，使用apply方法将其元素添加到arr1中
    arr1.push.apply(arr1, query);
  } else {
    // 如果query是一个数字，将其包装在数组中再添加到arr1中
    arr1.push(query);
  }
  console.info(arr1);
  return request({
    url:'/bidding/demand/delProjectID',
    method:'post',
    data:arr1,
  })
}
